package com.example.inventoryservice.controller;

import com.example.inventoryservice.service.InventoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/inventory")
public class InventoryController {

    @Autowired
    private InventoryService inventoryService;

    @GetMapping("/{productId}")
    public Integer getInventory(@PathVariable String productId) {
        return inventoryService.getInventory(productId);
    }

    @PostMapping("/deduct")
    public Boolean deductInventory(@RequestParam String productId, @RequestParam Integer count) {
        return inventoryService.deductInventory(productId, count);
    }
}
    